<!DOCTYPE html>
<!-- saved from url=(0056)https://blog.csdn.net/yaya_1q2w/article/details/79468098 -->
<html lang="zh-CN">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="renderer" content="webkit">
    <meta name="force-rendering" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="report" content="{&quot;pid&quot;:&quot;blog&quot;}">
    <meta name="referrer" content="always">
    <meta http-equiv="Cache-Control" content="no-siteapp">
    <title>Xpath,CSS定位速查表</title>
</head>
<body>
<div class="main_father clearfix d-flex justify-content-center" style="height:100%;width:1200px;margin:0 auto">
    <div class="container clearfix" id="mainBox">
        <main>
            <div class="blog-content-box">
                <div class="article-header-box">
                    <div class="article-header">
                        <div class="article-title-box">
                            <h1 class="title-article">Xpath,CSS定位速查表</h1>
                        </div>
                    </div>
                </div>
                <article class="baidu_pl">
                    <!--python安装手册开始-->
                    <!--python安装手册结束-->
                    <!--####专栏广告位图文切换开始-->
                    <!--####专栏广告位图文切换结束-->
                    <div id="article_content" class="article_content clearfix">
                        <link rel="stylesheet" href="./Xpath,CSS manul_files/ck_htmledit_views-833878f763.css">
                        <div class="htmledit_views" id="content_views">
                            <div class="table-box">
                                <table>
                                    <thead>
                                    <tr>
                                        <th>描述</th>
                                        <th>Xpath</th>
                                        <th>CSS Path</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <tr>
                                        <td>直接子元素</td>
                                        <td>//div/a</td>
                                        <td>div &gt; a</td>
                                    </tr>
                                    <tr>
                                        <td>子元素或后代元素</td>
                                        <td>//div//a</td>
                                        <td>div a</td>
                                    </tr>
                                    <tr>
                                        <td>以id定位</td>
                                        <td>//div[@id=’idValue’]//a</td>
                                        <td>div#idValue a</td>
                                    </tr>
                                    <tr>
                                        <td>以class定位</td>
                                        <td>//div[@class=’classValue’]//a</td>
                                        <td>div.classValue a</td>
                                    </tr>
                                    <tr>
                                        <td>同级弟弟元素</td>
                                        <td>//ul/li[@class=’first’]/following-sibling::li</td>
                                        <td>ul&gt;li.first + li</td>
                                    </tr>
                                    <tr>
                                        <td>属性</td>
                                        <td>//form/input[@name=’username’]</td>
                                        <td>form input[name=’username’]</td>
                                    </tr>
                                    <tr>
                                        <td>多个属性</td>
                                        <td>//input[@name=’continue’ and @type=‘button’]</td>
                                        <td>input[name=’continue’][type=’button’]</td>
                                    </tr>
                                    <tr>
                                        <td>第4个子元素</td>
                                        <td>//ul[@id=’list’]/li[4]</td>
                                        <td>ul#list li:nth-child(4)</td>
                                    </tr>
                                    <tr>
                                        <td>第1个子元素</td>
                                        <td>//ul[@id=’list’]/li[1]</td>
                                        <td>ul#list li:first-child</td>
                                    </tr>
                                    <tr>
                                        <td>最后1个子元素</td>
                                        <td>//ul[@id=’list’]/li[last()]</td>
                                        <td>ul#list li:last-child</td>
                                    </tr>
                                    <tr>
                                        <td>属性包含某字段</td>
                                        <td>//div[contains(@title,’Title’)]</td>
                                        <td>div[title*=”Title”]</td>
                                    </tr>
                                    <tr>
                                        <td>属性以某字段开头</td>
                                        <td>//input[starts-with(@name,’user’)]</td>
                                        <td>input[name^=”user”]</td>
                                    </tr>
                                    <tr>
                                        <td>属性以某字段结尾</td>
                                        <td>//input[ends-with(@name,’name’)]</td>
                                        <td>input[name$=”name”]</td>
                                    </tr>
                                    <tr>
                                        <td>text中包含某字段</td>
                                        <td>//div[contains(text(), ‘text’)]</td>
                                        <td>无法定位</td>
                                    </tr>
                                    <tr>
                                        <td>元素有某属性</td>
                                        <td>//div[@title]</td>
                                        <td>div[title]</td>
                                    </tr>
                                    <tr>
                                        <td>父节点</td>
                                        <td>//div/..</td>
                                        <td>无法定位</td>
                                    </tr>
                                    <tr>
                                        <td>同级哥哥节点</td>
                                        <td>//li/preceding-sibling::div[1]</td>
                                        <td>无法定位</td>
                                    </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </article>
            </div>
        </main>
    </div>
</div>
</body>
</html>